{% extends "base_tmp.html" %}

{% block css %}

<link rel="stylesheet" href="/static/base/css/msg_style.css">
{% endblock %}

{% block content %}

<!--内容-->
<div class="container" style="margin-top:76px">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-info">
                <div class="panel-heading">
                    <h3 class="panel-title"><span class="glyphicon glyphicon-list-alt"></span>&nbsp;会员注册</h3>
                </div>
                <div class="panel-body">

                    <form action="{% url 'user:register' %}" method="post" class="smart-green">

                        <h1>用户注册</h1>

                        <!--
                        {{ form.as_p }}
                        -->

                       {{ form.username.label }}
                       {{ form.username }}
                        <a style="color: red">{{ form.username.errors }}</a>

                        {{ form.password.label }}
                       {{ form.password }}
                       <a style="color: red">{{ form.password.errors }}</a>

                       {{ form.email.label }}
                       {{ form.email }}
                        {{ form.email.errors }}

                        {{ form.captcha.errors }}
                      {{ form.captcha.label_tag }}
                      {{ form.captcha }}

                         {% if messages %}
                           <ul>
                              {% for msg in messages %}
                                <li style="color: red">{{msg.message}}</li>
                               {% endfor %}
                           </ul>
                        {% endif %}

                        <div class="success-msg"></div>
                        <label>
                            <span>&nbsp;</span>
                            <input type="submit" class="button" value="提交注册"/>
                        </label>

                        <label>
                            <span>已有账号？请点击 <a href="{% url 'user:login' %}">登录</a></span>
                        </label>

                    </form>

                </div>
            </div>
        </div>

    </div>
</div>
<!--内容-->

{% endblock %}

{% block js %}
<script language="JavaScript">
$(function () {
    {## ajax 刷新#}
    $('.captcha').click(function(){
        console.log('click');
         $.getJSON("/captcha/refresh/",
                  function(result){
             $('.captcha').attr('src', result['image_url']);
             $('#id_captcha_0').val(result['key'])
          });});
})
</script>
{% endblock %}